﻿package app.view.components.sections 
{
	import app.view.components.header.HeadMarkerBase;
	import app.view.components.sections.Section;
	
	/**
	 * Секция с Label
	 * @author firsoff maxim, snzflash.com, tel: +79222345364, skype: maxim.firsoff
	 */
	public class LabeledSectionBase extends Section
	{
		public var headMarker:HeadMarkerBase;
		
		private static const HEAD_X:Number = -20;
		private static const HEAD_Y:Number = 170;
		
		
		public function LabeledSectionBase() 
		{
			super();
		};
		
		override protected function init():void 
		{
			super.init();
			
		};
		
		private function buildHead():void
		{
			
			headMarker = new HeadMarkerBase();
			headMarker.visible = false;
			headMarker.x = HEAD_X;
			headMarker.y = HEAD_Y;
			addChild(headMarker);
			
		}
		
		public function setParamHead(color:String='BGD_ORANGE',str:String=''):void
		{
			
			if (str=='') 
			{
				//str = String(_data.data.head[1].text).substr(1);
				
				for each(var object:* in _data.data.head)
				{
					str = String(object.text).substr(1);
				}
				
			}
			
			headMarker.visible = true;
			headMarker.setHeadText(str);
			headMarker.setBgdColor(color);
			addChild(headMarker);
			headMarker.show();
			
			//trace('head= ', String(_data.data.head[1].text).substr(1));
		}
		
		
		
		override public function onDestroy():void 
		{
			try 
			{
				if (headMarker) 
				{
					removeChild(headMarker);
				}
			}catch (err:Error){}
			
			
			super.onDestroy();
		};
		
		override public function get data():Object { return _data; };
		
		override public function set data(value:Object):void 
		{
			buildHead();
			
			super.data = value;
			
			
			
		};
		
		
		
	};
};